#include <bits/stdc++.h>
using namespace std;
int men[20];
int main() {
  int N, M, K;
  cin >> N >> M >> K;
  // map<int, int> mp;
  for (int i = 1; i <= K; i++) {
    int a, b;
    cin >> a >> b;
    // mp[a]++;
    men [a]++;
     
    if (men[a] == M) {
      cout << a << " ";
    }

  }
  return 0;
}
